﻿using System.Collections.Generic;

public class GameStageManager : FsmControllerBase<StageType>
{
    public class StageTypeComparer : IEqualityComparer<StageType>
    {
        public bool Equals(StageType x, StageType y) {
            return (int)x == (int)y;
        }
        public int GetHashCode(StageType x) { return (int)x; }
    }

    private static GameStageManager instance;
    public static GameStageManager Instance
    {
        get
        {
            if (instance == null)
            {
                instance = new GameStageManager();
                instance.InitState();
            }

            return instance;
        }
    }

    public override void InitState()
    {
        base.InitState(new StageTypeComparer());
        AddState(StageType.HotUpdate, new HotUpdateStage(StageType.HotUpdate, this));
        AddState(StageType.Login, new LoginStage(StageType.Login, this));
        AddState(StageType.ChoseRole, new ChoseRoleStage(StageType.ChoseRole, this));
        AddState(StageType.World, new WorldStage(StageType.World, this));
    }
    
    public bool GameRunning
    {
        get { return IsInXState(StageType.World); }
    }
}